package com.wangyi.sdk;

import java.util.ArrayList;

/**
 * 
 * @author vernon 20140406 创建类
 */
public class Group {
	private String name;
	private String id;
	private long user_id;
	private int tb_id;

	public int getTb_id() {
		return tb_id;
	}

	public void setTb_id(int tb_id) {
		this.tb_id = tb_id;
	}

	public long getUser_id() {
		return user_id;
	}

	public void setUser_id(long user_id) {
		this.user_id = user_id;
	}

	public Group(String name, String id) {
		super();
		this.name = name;
		this.id = id;
	}

	public Group() {
		super();
	}

	public Group(JSONObject jsonObject) {
		try {
			this.name = jsonObject.getString("name");
			this.id = jsonObject.getString("id");
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public ArrayList<Group> getGroupList(Response res) throws TBlogException {
		try {
			JSONArray jsonArray = res.asJSONArray();
			ArrayList<Group> groupList = new ArrayList<Group>();

			for (int i = 0; i < jsonArray.length(); i++) {
				groupList.add(new Group(jsonArray.getJSONObject(i)));
			}
			return groupList;
		} catch (JSONException jsone) {
			throw new TBlogException(jsone);
		}
	}

	@Override
	public String toString() {
		return "Group [name=" + name + ", id=" + id + ", user_id=" + user_id + "]";
	}

}
